with open('test.txt', 'w', encoding='UTF-8')as f:
    f.write('"wow,so beautiful!"')
with open('test.txt', encoding='UTF-8')as f:
    print(f.read())
with open('a.txt', 'w', encoding='UTF-8')as f:
    f.write('张三，李四，王五，赵六\n')
with open('a.txt', encoding='UTF-8')as f:
    my_list = f.read().split('，')
print(my_list)
import json

my_dict = {'name': 'isaac', 'age': 18, 'like': ['学习', '游戏']}
with open('test2.json', 'w', encoding='UTF-8')as j:
    json.dump(my_dict, j, ensure_ascii=False, indent=2)
with open('test.json', encoding='UTF-8')as j:
    result = json.load(j)
for x in result:
    if 'name' in x and x.get('name') == '小明':
        print('小明的年纪是', x.get('age'), sep='')
        print('小明的爱好是', x.get('hobby')[0], x.get('hobby')[1], x.get('hobby')[2], x.get('hobby')[3], sep='')
import random

y = 1
lst = []
while y <= 10:
    y += 1
    lst.append(str(random.randint(1, 20)))
print(lst)
with open('data.txt', 'w', encoding='UTF-8')as f:
    for z in lst:
        f.write(z)
        f.write(',')
with open('data.txt', encoding='UTF-8')as f:
    sorted_result = f.read().split(',')[:10]
    lst1 = []
    for a in sorted_result:
        lst1.append(int(a))
    lst1.sort(reverse=True)
    print(lst1)
with open('data1.txt', 'w', encoding='UTF-8')as f:
    f.write(f'{lst1[:5]}')
try:
    num = int(input('请输入一个整数：'))
except Exception as e:
    print(f'很遗憾，因为你的错误输入导致程序运行时发生了异常：{e}')
else:
    if not num % 2:
        print(f'你方才输入的数字是{num}，它是个偶数。')
    else:
        print(f'你方才输入的数字是{num}，它是个奇数。')
print('程序运行结束')
num1 = input('请输入一个整数：')
if num1 == '':
    print('你输入的不是整数...')
elif num1[0] == '-' or num1[0] == '+':
    if num1[1:].isdigit():
        if not int(num1[1:]) % 2:
            print(f'你方才输入的数字是{num1}，它是个偶数。')
        else:
            print(f'你方才输入的数字是{num1}，它是个奇数。')
    else:
        print('你输入的不是整数...')
elif num1.isdigit():
    if not int(num1) % 2:
        print(f'你方才输入的数字是{num1}，它是个偶数。')
    else:
        print(f'你方才输入的数字是{num1}，它是个奇数。')
else:
    print('你输入的不是整数...')
print('程序运行结束')
